/*
 * Created by IntelliJ IDEA.
 * User: amrk
 * Date: 27/06/2004
 * Time: 16:30:43
 */
package com.talios.jira.feeds;

import org.jdom.Document;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;

import java.io.*;

public class InputStreamFeedBuilder extends AbstractFeedBuilder {
    InputStream is;

    public InputStreamFeedBuilder(InputStream inputStream) {
        is = inputStream;
    }

    public Document buildFeed() throws IOException, JDOMException {
        SAXBuilder builder = new SAXBuilder();

        BufferedReader in = new BufferedReader(new InputStreamReader(is));
        String inputLine;
        StringBuffer buffer = new StringBuffer();
        while ((inputLine = in.readLine()) != null) {
            buffer.append(inputLine);
            buffer.append('\n');
        }

        in.close();
        String content = processUndeclaredEntities(buffer.toString());
        StringReader reader = new StringReader(content);

        Document doc = builder.build(reader);
        return doc;
    }

    public String buildRssFeedUrl(boolean includeUserDetails) {
        return "";
    }

    public String getSearchFor() {
        return "";
    }
}